package jdbc_practice;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class PWDDemo {
    public static void main(String[] args) {
        try(Connection connection = DBUtil.getConnection();) {
            String sql ="UPDATE user\n" +
                    "SET password =? ,nickname = ?,age= ?" +
                    "WHERE username=?";
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setString(1,"123456");
            ps.setString(2,"老四");
            ps.setInt(3,33);
            ps.setString(4,"赵四");
            int num = ps.executeUpdate();
            System.out.println(num>0?"修改成功":"修改失败");
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
